<?php


namespace app\applet\controller;

use app\share\model\Token;


class GoodsShare
{
    public function __construct()
    {
        $this->token=new Token();
        $this->goods=new \app\applet\model\GoodsShare();
    }

    /**
     *干货分享 轮播图
     */
    public function banner(){
        $returnData=$this->goods->banner();
        returnJson(200,"success",$returnData);
    }


    /**
     * 干货分享  热门(裂变)  精选（返利） 课程
     */
    public function courses(){
        $returnData=$this->goods->hotCourse();
        returnJson(200,"success",$returnData);
    }

    /**
     * 干货分享 我的课程 （我购买或者观看过的课程）
     */
    public function myCourse(){
        $member_id = get_header_id("token");
        //$member_id=8;

        $returnData=$this->goods->myCourse($member_id);
        returnJson(200,"success",$returnData);
    }

    /**
     * 干货分享 商品详情  type   1=热门(裂变) 2=精选（返利）
     */
    public function goodsDetail(){
        $member_id = get_header_id("token");
        //$member_id=8;
        $param=input();

        $returnData=$this->goods->goodsDetail($member_id,$param['goods_id']);

        returnJson(200,"success",$returnData);
    }

    /**
     * 干货分享 商品列表   type  1=热门(裂变) 2=精选（返利）
     */
    public function goodsList(){
        $param=input();
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];
        $type=empty($param['type']) ? 1: $param['type'];

        $returnData=$this->goods->goodsList($page,$page_size,$type);

        returnJson(200,'success',$returnData);
    }

    /**
     * 干货分享 我的课程列表
     */
    public function myCourseList(){
        $member_id = get_header_id("token");
        //$member_id=8;
        $param=input();
        $page=empty($param['current_page']) ? 1 : $param['current_page'];
        $page_size=empty($param['page_num']) ? 10: $param['page_num'];


        $returnData=$this->goods->myCourseList($member_id,$page,$page_size);

        returnJson(200,'success',$returnData);
    }

    /**
     * 干货分享  免费试看 写入观看记录
     */
    public function freeTrial(){
        $member_id = get_header_id("token");
        //$member_id=8;
        $goods_id=input('goods_id');

        $this->goods->videoSee($goods_id,$member_id);
        returnJson(200,'操作成功');
    }
}